package com.huidz.calendar.activityadapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.huidz.calendar.R;

import java.util.ArrayList;

public class HuangliAdapter extends BaseAdapter {
    ArrayList<String> list;
    Context context;

    public HuangliAdapter(ArrayList<String> list, Context context) {
        // TODO Auto-generated constructor stub
        this.list = list;
        this.context = context;
    }

    @Override
    public int getCount() {
        // TODO Auto-generated method stub
        return list != null ? list.size() : 0;
    }

    @Override
    public Object getItem(int position) {
        // TODO Auto-generated method stub
        return list != null ? list.get(position) : 0;
    }

    @Override
    public long getItemId(int position) {
        // TODO Auto-generated method stub
        return position;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        // TODO Auto-generated method stub
        convertView = LayoutInflater.from(context).inflate(R.layout.fragment_hllistitem, null);
        init i = new init();
        i.xiongji = convertView.findViewById(R.id.xiongji);
        i.hlitem_text = convertView.findViewById(R.id.hlitem_text);
        i.homeitem_text = convertView.findViewById(R.id.homeitem_text);
        i.homeitem_tiem = convertView.findViewById(R.id.homeitem_tiem);
        i.homeitem_type = convertView.findViewById(R.id.homeitem_type);
        i.hl_list_yitext = convertView.findViewById(R.id.hl_list_yitext);
        i.hl_list_jitext = convertView.findViewById(R.id.hl_list_jitext);
        i.xiongji_rela = convertView.findViewById(R.id.xiongji_rela);
        if (position % 3 == 0) {
            i.xiongji_rela.setBackgroundResource(R.drawable.hl_list_redse);
            i.xiongji.setText("吉");
        }

        switch (position) {
            case 0:
                i.hlitem_text.setText("子");
                break;
            case 1:
                i.hlitem_text.setText("丑");

                break;
            case 2:
                i.hlitem_text.setText("寅");

                break;
            case 3:

                i.hlitem_text.setText("卯");
                break;
            case 4:

                i.hlitem_text.setText("辰");
                break;
            case 5:
                i.hlitem_text.setText("巳");

                break;
            case 6:
                i.hlitem_text.setText("午");

                break;
            case 7:

                i.hlitem_text.setText("未");
                break;
            case 8:

                i.hlitem_text.setText("申");
                break;
            case 9:

                i.hlitem_text.setText("酉");
                break;
            case 10:

                i.hlitem_text.setText("戌");
                break;
            case 11:
                i.hlitem_text.setText("亥");

                break;
        }
        convertView.setTag(i);
        return convertView;
    }

    public static class init {
        //首页list的子控件
        TextView xiongji, hlitem_text, homeitem_text, homeitem_tiem, homeitem_type, hl_list_yitext, hl_list_jitext;
        RelativeLayout xiongji_rela;
    }
}

